package notes;

/**
 * Description:
 *
 * @Author cowen
 * @Create 2023/10/19 15:10
 * @Version 1.0
 */
//冒泡排序
class ArrayBubbleSort{
    public static void main(String[] args) {
        int[] nums = {11,22,55,33,44,78,9,158,23};
        System.out.println("======原数组======");
        for (int i = 0; i < nums.length; i++) {
            System.out.print(nums[i]+",");
        }
        // 冒泡排序
        for (int j = 0; j < nums.length-1; j++) {
            for (int i = 0; i < nums.length-1-j; i++) {
                if(nums[i]>nums[i+1]){
                    int temp = nums[i];
                    nums[i]=nums[i+1];
                    nums[i+1]=temp;
                }
            }
        }
        System.out.println("======排序后数组======");
        for (int i = 0; i < nums.length; i++) {
            System.out.print(nums[i]+",");
        }
    }
}
